package com.example.micrtask;

import com.example.common.util.HttpClientUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.example.api.service.IncomeService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.net.http.HttpClient;
import java.util.Date;

/**
 * @description: TODO
 * @author: uu
 * @data: 2023/7/22 上午 11:02
 * @version: v1.0
 */
@Component
public class TaskManager {

//    @Scheduled(cron = "1/5 6/1 11 * * ?")
//    public void testCron(){
//        System.out.println(new Date());
//    }
    @DubboReference(interfaceClass = IncomeService.class, version = "1.0")
    private IncomeService incomeService;


    @Scheduled(cron = "0 0 1 * * ?")
    /*生成收益计划*/
    public void invokeGenerateIncomePlan(){
        incomeService.generateIncomePlan();
    }

    @Scheduled(cron = "0 0 2 * * ?")
    /*生成收益返还*/
    public void invokeGenerateIncomeBack(){
        incomeService.generateIncomeBack();
    }

    @Scheduled(cron = "0/10 0 * * * ?")
    /*补单*/
    public void invokeQueryKQ(){
        String url = "http://localhost:9000/pay/kq/query";
        try {
            HttpClientUtils.doGet(url);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
